import { createStore } from 'vuex';
import { LoginParams } from '@/utils/api/user';
export default createStore({
  state: {
    activeHeadItem: 'main',
    //有关用户登录信息的参数
    userInfo: {
      isLogin: false,
      isAdministrator: false,
      username: '',
      password: '',
    },
    activeAdminNavItem: 'dashboard',
    //订票框
    formData: {
      departureCity: '',
      arrivalCity: '',
      departureDate: new Date(),
      returnDate: '',
      passengerInfo: '',
      pAmount: [0, 0, 0],
      radio: true,
    },
    //选票情况
    ticketInfo: {
      flightId: '',
      departureDate: '',
      ticketType: '',
      price: '',
      pAmount: [0,0,0],
    },
  },
  mutations: {
    changeActiveHead(state, newItem) {
      state.activeHeadItem = newItem;
    },
    changeActiveAdminNav(state, newItem) {
      state.activeAdminNavItem = newItem;
    },
    changeFormData(state, newItem) {
      state.formData = newItem;
    },
    changeDD(state, newItem) {
      state.formData.departureDate = newItem;
    },
    updateTicketInfo(state, newItem) {
      state.ticketInfo = newItem;
    },
    login(state,userInfo) {
      state.userInfo = userInfo;
    },
    logout(state) {
      state.userInfo.isLogin = false;
      state.userInfo.isAdministrator = false;
      state.userInfo.username = '';
      state.userInfo.password = '';
    },
  },
  actions: {},
  modules: {},
});
